<?php
namespace  plugin\banmitongcheng\admin; 
use  plugin\banmitongcheng\model\PluginBanmitongchengShopList; 
use  plugin\banmitongcheng\validate\ShoplistValidate;
use app\admin\common\Baseadmin;
use think\facade\Db; 

class Shoplist extends Baseadmin
{
 
 
       
      /**333
      * @notes  商家列表 
      * @variable   
      * @date 2022-12-03 16:53:30
      * @author 半米科技低代码一键生成
      */
      public function   paginate_sjlb(){  
             $request= (new ShoplistValidate())->IsCheck();
             $field="id,nav_id,shop_name,shop_img,shop_tel,shop_tag,shop_addr,shop_lng,shop_lat,business_time,sort,status,creation_time,uid,creation_ip,top_end_time,vip_end_time";
         
                  $map=[
                  ['status',	'>='   ,    0 ],
                  ];
             $model =(new PluginBanmitongchengShopList())->paginate($map,$field);
             $data['list']=$model;
             ajaxmsg('ok', 200,$data);  
      }
       
      /**
      * @notes  删除商家 
      * @variable  id=id;status=; 
      * @date 2022-12-04 20:00:00
      * @author 半米科技低代码一键生成
      */
      public function   updates_scsj(){  
             $request= (new ShoplistValidate())->IsCheck('scsj');
             $field=["status"];
             $request['status']= -1;
             $map=[
                  ['id',	'='   ,    input('request.id')  ],
                  ];
             $model =(new PluginBanmitongchengShopList())->updates($map,$request,$field);
              if($model){
    
               Db::name('plugin_banmitongcheng_statistics')->where('id', 1)
              ->dec('shop_num')
              ->update();
               ajaxmsg('更新成功', 200);
              }
               ajaxmsg('更新失败', 0);  
      }
       
      /**
      * @notes  置顶 
      * @variable  id=id;sort=sort; 
      * @date 2022-12-05 17:59:45
      * @author 半米科技低代码一键生成
      */
      public function   updates_zd(){  
             $request= (new ShoplistValidate())->IsCheck('zd');
             $field=["sort"];
             $map=[
                  ['id',	'='   ,    input('request.id')  ],
                  ];
             $model =(new PluginBanmitongchengShopList())->updates($map,$request,$field);
              if($model){
               ajaxmsg('更新成功', 200);
              }
               ajaxmsg('更新失败', 0);  
      }
            /**
      * @notes  置顶1天 
      * @variable  id=id;sort=sort; 
      * @date 2022-12-05 17:59:45
      * @author 半米科技低代码一键生成
      */
      public function   updates_zd_top(){  
             $request= (new ShoplistValidate())->IsCheck('zd');
             $field=["sort","top_end_time"];
             $request['top_end_time']=time() + 86400;
             $map=[
                  ['id',	'='   ,    input('request.id')  ],
                  ];
             $model =(new PluginBanmitongchengShopList())->updates($map,$request,$field);
              if($model){
               ajaxmsg('置顶成功', 200);
              }
               ajaxmsg('更新失败', 0);  
      }
           /**
      * @notes  审核拒绝 
      * @variable  id=id;status=; 
      * @date 2022-12-05 18:29:02
      * @author 半米科技低代码一键生成
      */
      public function   updates_jujue(){  
           
         
             $text =input('request.text');
             $map=[
                  ['id',	'='   ,    input('request.id')  ],
                  ];
            //  $model =(new PluginBanmitongchengShopList())->updates($map,$request,$field);
             
           $model =  Db::name('plugin_banmi_tongcheng_shop_list')->where($map)->update(['status' =>0 , 'refuse_text' =>$text  ]);
             
              if($model){
               ajaxmsg('更新成功', 200);
              }
               ajaxmsg('更新失败', 0);  
      }  
      /**
      * @notes  审核通过 
      * @variable  id=id;status=; 
      * @date 2022-12-05 18:29:02
      * @author 半米科技低代码一键生成
      */
      public function   updates_shtg(){  
             $request= (new ShoplistValidate())->IsCheck('shtg');
             $field=["status"];
             $request['status']= 2;
             $map=[
                  ['id',	'='   ,    input('request.id')  ],
                  ];
             $model =(new PluginBanmitongchengShopList())->updates($map,$request,$field);
              if($model){
               ajaxmsg('更新成功', 200);
              }
               ajaxmsg('更新失败', 0);  
      }
       
      /**
      * @notes  查询商家 
      * @variable  shop_tel=手机号;uid=uid; 
      * @date 2022-12-05 19:30:10
      * @author 半米科技低代码一键生成
      */
      public function   paginate_cxsj(){  
             $request= (new ShoplistValidate())->IsCheck('cxsj');
             $field="id,nav_id,shop_name,shop_img,shop_tel,shop_tag,shop_addr,shop_lng,shop_lat,business_time,creation_ip,uid,creation_time,status,sort";
             $map=[
                //   ['shop_tel',	'='   ,    input('request.shop_tel')  ],
                  ['uid',	'='   ,    input('request.uid')  ],
                  ];
             $model =(new PluginBanmitongchengShopList())->paginate($map,$field);
             $data['list']=$model;
             ajaxmsg('ok', 200,$data);  
      }
       
      /**
      * @notes  查询商家详情 
      * @variable  id=id; 
      * @date 2023-03-24 13:53:07
      * @author 半米科技低代码一键生成
      */
      public function   finds_cxsjxq(){  
             $request= (new ShoplistValidate())->IsCheck('cxsjxq');
             $field="id,nav_id,shop_name,shop_img,shop_tel,shop_tag,shop_addr,shop_lng,shop_lat,business_time,creation_ip,uid,creation_time,status,refuse_text,sort,vip_end_time,top_end_time";
             $map=[
                  ['id',	'='   ,    input('request.id')  ],
                  ];
             $model =(new PluginBanmitongchengShopList())->finds($map,$field);
             $model['creation_time']=date('Y-m-d H:i:s',$model['creation_time']);
      
             $data['find']=$model;
             ajaxmsg('ok', 200,$data);  
      }
       
      /**
      * @notes  编辑商家信息 
      * @variable  id=id;shop_name=商家名称;nav_id=分类id;shop_tel=手机号;shop_tag=标签;shop_addr=商家地址;business_time=营业时间;creation_time=入驻时间; 
      * @date 2023-03-24 14:30:57
      * @author 半米科技低代码一键生成
      */
      public function   updates_bjsjxx(){  
             $request= (new ShoplistValidate())->IsCheck('bjsjxx');
             $field=["shop_name","shop_img","nav_id","shop_tel","shop_tag","shop_addr","business_time","creation_time","vip_end_time","top_end_time"];
             $request['creation_time']=strtotime($request['creation_time']);
             
              $map=[
                  ['id',	'='   ,    input('request.id')  ],
                  ];
             $model =(new PluginBanmitongchengShopList())->updates($map,$request,$field);
              if($model){
               ajaxmsg('更新成功', 200);
              }
               ajaxmsg('更新失败', 0);  
      }
      //控制器方法
    
    
    
}